]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
workspacesView: Avoid setting invalid geometries on views
authorJonas Dreßler <verdre@v0yd.nl>
Wed, 20 May 2020 10:05:04 +0000 (12:05 +0200)
committerFlorian Müllner <florian.muellner@gmail.com>
Sun, 14 Jun 2020 14:44:10 +0000 (14:44 +0000)
The fullGeometry and the actualGeometry of the WorkspacesDisplay are set
from the allocation of the overviews ControlsManager and the
WorkspacesDisplay, that means they're only valid after those actors got
their allocations during Clutters allocation cycle.

Since WorkspacesDisplay._updateWorkspacesViews() is already called while
showing/mapping the WorkspacesDisplay, that allocation cycle didn't
happen yet and we end up either setting the geometries of the views to
null (in case of the fullGeometry) or to something wrong (a 0-sized
allocation in case of the actualGeometry).

So avoid setting invalid geometries on the views by initializing both
the fullGeometry and the actualGeometry to null, and then only updating
the geometries of the views after they're set to a correct value.

Note that this means we won't correctly animate the overview the first
time we open it since the animation depends on the geometries being set,
but is being started from show(), which means no allocations have
happened yet. In practice this introduces no regression though since
before this change we simply used incorrect geometries (see the 0-sized
allocation mentioned above) on the initial opening and the animation
didn't work either.

https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1119

js/ui/workspacesView.js

index 335344eb0a0b6b335dd42f084b5b058abe36e53d..e33528db0f1fd5382960bd9c68c7219e395b72f0 100644 (file)
@@ -453,6 +453,7 @@ class WorkspacesDisplay extends St.Widget {
         this._keyPressEventId = 0;
         this._scrollTimeoutId = 0;
 
+        this._actualGeometry = null;
         this._fullGeometry = null;
         this._inWindowDrag = false;
 
@@ -696,8 +697,10 @@ class WorkspacesDisplay extends St.Widget {
 
         this._workspacesViews.forEach(v => v.show());
 
-        this._updateWorkspacesFullGeometry();
-        this._updateWorkspacesActualGeometry();
+        if (this._fullGeometry)
+            this._syncWorkspacesFullGeometry();
+        if (this._actualGeometry)
+            this._syncWorkspacesActualGeometry();
     }
 
     _getMonitorIndexForEvent(event) {
@@ -749,10 +752,10 @@ class WorkspacesDisplay extends St.Widget {
     // the sliding controls were never slid in at all.
     setWorkspacesFullGeometry(geom) {
         this._fullGeometry = geom;
-        this._updateWorkspacesFullGeometry();
+        this._syncWorkspacesFullGeometry();
     }
 
-    _updateWorkspacesFullGeometry() {
+    _syncWorkspacesFullGeometry() {
         if (!this._workspacesViews.length)
             return;
 
@@ -764,18 +767,21 @@ class WorkspacesDisplay extends St.Widget {
     }
 
     _updateWorkspacesActualGeometry() {
+        const [x, y] = this.get_transformed_position();
+        const width = this.allocation.get_width();
+        const height = this.allocation.get_height();
+
+        this._actualGeometry = { x, y, width, height };
+        this._syncWorkspacesActualGeometry();
+    }
+
+    _syncWorkspacesActualGeometry() {
         if (!this._workspacesViews.length)
             return;
 
-        let [x, y] = this.get_transformed_position();
-        let allocation = this.allocation;
-        let width = allocation.x2 - allocation.x1;
-        let height = allocation.y2 - allocation.y1;
-        let primaryGeometry = { x, y, width, height };
-
         let monitors = Main.layoutManager.monitors;
         for (let i = 0; i < monitors.length; i++) {
-            let geometry = i == this._primaryIndex ? primaryGeometry : monitors[i];
+            let geometry = i === this._primaryIndex ? this._actualGeometry : monitors[i];
             this._workspacesViews[i].setActualGeometry(geometry);
         }
     }